const multer = require("multer"); //文件改名
const path = require("path");
const storage = multer.diskStorage({
  destination: (req, file, cb) => {
    //设置文件存储路径
    cb(null, './src/upload');
  },
  //设置文件存储名称
  filename: (req, file, cb) => {
    let extname = path.extname(file.originalname);
    filename = Date.now() + extname;
    req.body.imgUrl = '/upload/' + filename;
    console.log("文件存储的路劲", req.body.imgUrl);
    cb(null, filename);
  }
})
//公开配置
const upload = multer({
  storage: storage
})
module.exports = upload